import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ObjCreate } from "../../common/ObjCreate";
import { ResFileConst } from "../../../resource/ResFileConst";
import { FashionOperaPanel } from "./FashionOperaPanel";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { StatueUserPlayer } from "../../../scene/player/entity/StatueUserPlayer";
import { DirectionType } from "../../../scene/modle/data/DirectionType";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LadderBattlefieldUtil } from "../../ladderBattlefield/LadderBattlefieldUtil";
import { MsgManager } from "../../../manager/MsgManager";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EEntityAttribute } from "../../../../../Message/Public/EEntityAttribute";
import { EDressPos } from "../../../../../Message/Public/EDressPos";
import { PlayerEqStrengthInfo } from "./PlayerEqStrengthInfo";
import { Cache } from "../../../cache/Cache";
import { RolePlayer } from "../../../scene/player/entity/RolePlayer";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
type int = number;
//class EquipmentPanel
    
    export  class EquipmentPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._roleInfoBottomBg = new Object /* flash.display.Bitmap */();
            this._roleInfoBottomBg.x = 0;
            this._roleInfoBottomBg.y = 0;
            addChild(this._roleInfoBottomBg);
            LoaderHelp.setBitmapdata("RoleInfo_Bottom_Bg.swf", this._roleInfoBottomBg);
            this._contentSp = new Object /* flash.display.Sprite */();
            addChild(this._contentSp);
            this._hideShowBtn = ObjCreate.createGLoadedButton(ResFileConst.HideShow, 177, 265, 23, 41, this);
            this._hideShowBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onHideShowBtnClickHandler);
            this._wardrobeBtn = ObjCreate.createGLoadedButton(ResFileConst.WardrobeBtn, 50, 265, 23, 41, this);
            this._wardrobeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onWardrobeBtnClickHandler);
            this._fashionOperaPanel = new FashionOperaPanel();
            this._fashionOperaPanel.x = 205;
            this._fashionOperaPanel.y = 270;
            this._fashionOperaPanel.visible = false;
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemoveedToStageHandler);
            return;
        }

        public get showElfCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showElfCheckBox;
        }

        public addFilters(arg1: Boolean): void
        {
            if (arg1) 
            {
                this._contentSp.filters = [FilterConst.colorFilter2];
            }
            else 
            {
                this._contentSp.filters = [];
            }
            return;
        }

        /* internal  */addUserModel(arg1: int, arg2: int, arg3: int, arg4: Map<any, any> /* flash.utils.Dictionary */, arg5: int=0, arg6: int=0, arg7: int=0): void
        {
            if (this._userModel != null) 
            {
                this._userModel.dispose(false);
            }
            else 
            {
                this._userModel = new StatueUserPlayer();
            }
            this._userModel.direction = DirectionType.South;
            this._userModel.camp = arg1;
            this._userModel.sex = arg2;
            this._userModel.career = arg3;
            this._userModel.reserveJs.weaponStPerLv = arg5;
            this._userModel.reserveJs.wingStrPerLv = arg6;
            this._userModel.entityInfo.entityInfo.wuxingType = arg7;
            this._userModel.updateEquipByDic(arg4);
            this._userModel.wxPlayerShow();
            this._userModel.x = 135;
            this._userModel.y = 210;
            if (this._userModel.parent) 
            {
                if (this.getChildIndex(this._userModel) != 1) 
                {
                    setChildIndex(this._userModel, 1);
                }
            }
            else 
            {
                this._contentSp.addChildAt(this._userModel, 0);
            }
            return;
        }

        /* internal  */onAddedToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other || this._mode == GModuleEvent.Mode_ArenaCross || this._mode == GModuleEvent.Mode_Wrestle) 
                {
                    this.addUserModel(this._campOther, this._sexOther, this._careerOther, this._equipsDicOther, this._weaponStPerLv, this._wingStLv, this._wxType);
                }
            }
            else 
            {
                this.updateSelfInfo();
            }
            return;
        }

        /* internal  */onRemoveedToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._fashionOperaPanel.visible) 
            {
                this._fashionOperaPanel.visible = false;
            }
            if (this._userModel) 
            {
                this._userModel.dispose(false);
            }
            return;
        }

        /* internal  */onHideShowBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (LadderBattlefieldUtil.isInLadderBattlefield) 
            {
                MsgManager.showRollTipsMsg(Language.getString(28836));
                return;
            }
            if (this._fashionOperaPanel.visible) 
            {
                this._fashionOperaPanel.visible = false;
            }
            else 
            {
                this._fashionOperaPanel.visible = true;
                if (this.parent) 
                {
                    this.parent.addChild(this._fashionOperaPanel);
                }
            }
            return;
        }

        /* internal  */onWardrobeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FashionBoxModuleShow));
            return;
        }

        public updateRoleInfo(arg1: Array<any>, arg2: int, arg3: int, arg4: int, arg5: int, arg6: Boolean, arg7: Boolean, arg8: Boolean, arg9: Boolean, arg10: Boolean, arg11: Boolean): void
        {
            if (this._mode == GModuleEvent.Mode_Self || arg1 == null) 
            {
                return;
            }
            if (this._equipsDicOther != null) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeWeapon] = null;
                this._equipsDicOther[EEntityAttribute._EAttributeClothes] = null;
                this._equipsDicOther[EEntityAttribute._EAttributeWing] = null;
                this._equipsDicOther[EEntityAttribute._EAttributeSurround] = null;
                this._equipsDicOther[EEntityAttribute._EAttributeWaistBelt] = null;
                this._equipsDicOther[EEntityAttribute._EAttributeElf] = null;
            }
            else 
            {
                this._equipsDicOther = new Map<any, any> /* flash.utils.Dictionary */();
            }
            this._weaponStPerLv = 0;
            this._wingStLv = 0;
            var loc1=arg1[(EDressPos._EDressPosFashionWeapon - 1)];
            var loc2=arg1[(EDressPos._EDressPosWeapon - 1)];
            var loc3=arg1[(EDressPos._EDressPosFashion - 1)];
            var loc4=arg1[(EDressPos._EDressPosClothes - 1)];
            var loc5=arg1[(EDressPos._EDressPosWing - 1)];
            var loc6=arg1[(EDressPos._EDressPosSurround - 1)];
            var loc7=arg1[(EDressPos._EDressPosWaistBelt - 1)];
            var loc8=arg1[(EDressPos._EDressPosElf - 1)];
            if (!(loc1 == null) && !arg8) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeWeapon] = loc1.itemExInfo.weaponfashionModel;
            }
            else if (loc2 != null) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeWeapon] = loc2.data.itemCode;
                this._weaponStPerLv = PlayerEqStrengthInfo.getStrengthen(loc2);
            }
            if (!(loc3 == null) && !arg6) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeClothes] = loc3.itemExInfo.fashionModel;
            }
            else if (loc4 != null) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeClothes] = loc4.data.itemCode;
            }
            if (!(loc5 == null) && !arg7) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeWing] = loc5.itemExInfo.windModel;
                if (loc5.itemExInfo.useWingModelLv != 0) 
                {
                    this._wingStLv = loc5.itemExInfo.wingModelLv;
                }
                else 
                {
                    this._wingStLv = PlayerEqStrengthInfo.getStrengthen(loc5);
                }
            }
            if (!(loc6 == null) && !arg9) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeSurround] = loc6.itemExInfo.SUModel;
            }
            if (!(loc7 == null) && !arg10) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeWaistBelt] = loc7.itemExInfo.WBModel;
            }
            if (!(loc8 == null) && !arg11) 
            {
                this._equipsDicOther[EEntityAttribute._EAttributeElf] = loc8.itemExInfo.ELFModel;
            }
            this._campOther = arg3;
            this._careerOther = arg2;
            this._sexOther = arg4;
            this._wxType = arg5;
            this.addUserModel(this._campOther, this._sexOther, this._careerOther, this._equipsDicOther, this._weaponStPerLv, this._wingStLv, this._wxType);
            return;
        }

        public updateSelfInfo(): void
        {
            var loc4=0;
            var loc5=0;
            var loc1=Cache.instance.pack.rolePackCache.getAllItemsByCareer(this._curCareer);
            var loc2=loc1[(EDressPos._EDressPosWeapon - 1)];
            var loc3=loc1[(EDressPos._EDressPosWing - 1)];
            var loc6=RolePlayer.instance.entityInfo.entityInfo.wuxingType;
            if (loc2 != null) 
            {
                loc4 = RolePlayer.instance.reserveJs.weaponStPerLv;
            }
            if (loc3 != null) 
            {
                loc5 = RolePlayer.instance.reserveJs.wingStrPerLv;
            }
            var loc7=Cache.instance.role.getWeaponsDicByCareer(this._curCareer);
            this.addUserModel(RolePlayer.instance.camp, Cache.instance.role.entityInfo.sex, this._curCareer, loc7, loc4, loc5, loc6);
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                this._hideShowBtn.visible = false;
                this._wardrobeBtn.visible = false;
            }
            else 
            {
                this._hideShowBtn.visible = true;
                this._wardrobeBtn.visible = true;
            }
            return;
        }

        public set curCareer(arg1: int)
        {
            this._curCareer = arg1;
            return;
        }

        public get showFashionCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showFashionCheckBox;
        }

        public get showWingCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showWingCheckBox;
        }

        public get showFashWeaponCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showFashWeaponCheckBox;
        }

        public get showFootPrintCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showFootPrintCheckBox;
        }

        public get showBubbleCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showBubbleCheckBox;
        }

        public get showSurroundCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showSurroundCheckBox;
        }

        public get showWaistBeltCheckBox(): GCheckBox
        {
            return this._fashionOperaPanel.showWaistBeltCheckBox;
        }

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_curCareer: int;

        /* internal */ /* var */_contentSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_showFation: Boolean;

        /* internal */ /* var */_showWing: Boolean;

        /* internal */ /* var */_roleInfoBottomBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_fashionOperaPanel: FashionOperaPanel;

        /* internal */ /* var */_hideShowBtn: GLoadedButton;

        /* internal */ /* var */_wardrobeBtn: GLoadedButton;

        /* internal */ /* var */_campOther: int;

        /* internal */ /* var */_sexOther: int;

        /* internal */ /* var */_careerOther: int;

        /* internal */ /* var */_weaponStPerLv: int;

        /* internal */ /* var */_wingStLv: int;

        /* internal */ /* var */_wxType: int;

        /* internal */ /* var */_userModel: StatueUserPlayer;

        /* internal */ /* var */_equipsDicOther: Map<any, any> /* flash.utils.Dictionary */;
    }
